package top.lidee.common.service.twice.management.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.lidee.common.service.twice.management.MtSecondaryCateSpecialMapService;
import top.lidee.framework.result.PageUtils;
import top.lidee.module.backendApi.twice.page.Query;
import top.lidee.repository.mapper.twice.management.MtSecondaryCateSpecialMapMapper;
import top.lidee.repository.model.twice.pojo.management.MtSecondaryCateSpecialMapEntity;

import java.util.Map;
import java.util.Objects;

@Service("mtSecondaryCateSpecialMapService")
public class MtSecondaryCateSpecialMapServiceImpl extends ServiceImpl<MtSecondaryCateSpecialMapMapper, MtSecondaryCateSpecialMapEntity> implements MtSecondaryCateSpecialMapService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        Object key = params.get("key");

        IPage<MtSecondaryCateSpecialMapEntity> page = this.page(
                new Query<MtSecondaryCateSpecialMapEntity>().getPage(params),
                new LambdaQueryWrapper<MtSecondaryCateSpecialMapEntity>()
                        .eq(Objects.nonNull(key),MtSecondaryCateSpecialMapEntity::getSpecialTitle,key)
                        .or().eq(Objects.nonNull(key),MtSecondaryCateSpecialMapEntity::getCateId,key)
        );

        return new PageUtils(page);
    }

}